﻿var mec_id = "C67BC88322500001C79A1F3015CE1C9C";
var mainListScroll;
var mainListScroll1;
var mainListScroll2;
var mainListScroll3;
var mainListScroll4;
var itemKey  = "mobilemode_blog_mainList_data";
var pullDownEl;
var pullDownEl1;
var pullDownEl2;
var pullDownEl3;
var pullDownEl4;

var hScroll1;
var hScroll2;
$(document).ready(function(){
	//FastClick.attach(document.body);
	$(".tab > li").bind("click", function(){
		var $obj = $(this);
		var id = $obj.attr("id");
		var groupid = $obj.attr("groupid");
		if(groupid>0){
			if(!$obj.hasClass("selected")){
				$obj.siblings("li.selected").removeClass("selected");
				$obj.addClass("selected");
				if(groupid==0){
					refreshList();
				}else if(groupid==1){
					pageindex1 = 1;
					loadListByPageLoad(1);
					consoleGoTop(1);
				}else if(groupid==2){
					$("#keyword").val("");
					pageindex2 = 1;
					searchList1("main-panel-2");
				}else if(groupid==3){
					searchList1("main-panel-3");
				}
			}
		}
	});
	$(".monthTable li div.searchMonth ").bind("click", function(){
		var $obj = $(this);
		if($obj.hasClass("selected")){
			
		}else{
			$(".monthTable li div.selected").removeClass("selected");
			$obj.addClass("selected");
			searchList1("main-panel-3");
		}
	});
	
	$("#main-panel-4 .tbar > li").bind("click",function(){
		var $obj = $(this);
		if(!$obj.hasClass("selected")){
			$("#main-panel-4 .tbar > li").removeClass("selected");
			$obj.addClass("selected");
			
			var type = $obj.attr("type");
			var listSearch = $("#listSearch4");
			$("#keyword4").val("");
			var h = $("#main-panel-4 div.header")[0].clientHeight;
			var listpanel4 = $("#listpanel4");
			if(type=="wb"){//微博
				listpanel4.addClass("listBlog").removeClass("listContainer");
			}else if(type=="gz"){//关注
				listpanel4.addClass("listContainer").removeClass("listBlog");
			}else if(type=="fs"){//粉丝
				listpanel4.addClass("listContainer").removeClass("listBlog");
			}
			$("#NMEC_panel4.listContainerWrap").css("top", h);
			
			$("#main-panel-4 .tab .selected").attr("enddate","").attr("isload","0");
			$("#listpanel4 li").remove();
			pageindex4 = 1;
			
			searchList1("main-panel-4");
			consoleGoTop(4);
		}
	});
	
	initScroll(0);
	initScroll(1);
	initScroll(2);
	initScroll(4);
	refreshMainListScroll();
	loadListByPageLoad(0);
	
	$("#main-panel-2 .listSearch .btn").bind("click", function(){
		searchList1("main-panel-2");
	});
	
	$("#keyword").keyup(function(event){
		var keyCode = event.keyCode;
		if(keyCode == 13){
			searchList1("main-panel-2");
		}
	});
	
	$("#main-panel-4 .listSearch .btn").bind("click", function(){
		searchList1("main-panel-4");
	});
	
	$("#keyword4").keyup(function(event){
		var keyCode = event.keyCode;
		if(keyCode == 13){
			searchList1("main-panel-4");
		}
	});
	
	$("#main-panel-2 form[disabledEnterSubmit]").keydown(function(event){
		if(event.keyCode == 13){return false;}
	});
	//getBlogCount();
	getAttnRemindNum();
  
  var viewBlogId = parseInt($('#viewBlogId').val());
	if(viewBlogId > 0) {
		$('#scroll_footer').remove();
		$('.scroll_wrapper').css('bottom', '0');
		openBlog(viewBlogId);
	}
});


function isRunInEmobile(){
	return true;
}

function getBlogCount(){
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=getBlogCount&userid="+userid;
	$.get(url, function(responseText){
		var data = $.parseJSON(responseText);
		var updateCount = data["updateCount"];
		if(updateCount>0){
			$("#bcount").html(updateCount).show();
		}else{
			$("#bcount").hide();
		}
	});
}

function getAttnRemindNum(){
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=getAttnRemindNum&userid="+userid;
	$.get(url, function(responseText){
		var data = $.parseJSON(responseText);
		
		if(data>0){
			$(".btnTopRightMsgNum").html(data).show();
			$("#attnRemindNum").html(data).show();
		}else{
			$(".btnTopRightMsgNum").hide();
			$("#attnRemindNum").hide();
		}
	});
}

function dealrequest(relatedid,id,status){
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=dealrequest&relatedid="+relatedid+"&requestid="+id+"&status="+status+"&userid="+userid;
	$.get(url, function(responseText){
		if(status==1){
			$("#reminda"+id).html("已同意");
		}else{
			$("#reminda"+id).html("已拒绝");
		}
		getAttnRemindNum();
	});

}

function getAttnRemindMsg(){
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=getAttnRemindMsg&userid="+userid;
	$.get(url, function(responseText){
		var data = $.parseJSON(responseText);
		$("#remindPanelTb").html("");
		if(data.length && data.length>0){

		for(var i=0;i<data.length;i++){
			var htmli="<tr><td width=\"1%\"></td><td width=\"70%\"><div>"+data[i].username
			+"&nbsp;&nbsp;向你申请关注</div></td>";
			htmli += "<td width=\"25%\"><div id=\"reminda"+data[i].id+"\">"
			+"<a style=\"color: #1d76a4;\" href=\"javascript:dealrequest("+data[i].relatedid+","+data[i].id+",'1');\">同意</a>"
			+"&nbsp;&nbsp;&nbsp;<a style=\"color: #1d76a4;\" href=\"javascript:dealrequest("+data[i].relatedid+","+data[i].id+",'-1');\">拒绝</a></div></td>"
			+"<td width=\"1%\"></td>";
			$("#remindPanelTb").append(htmli);
		}
		}else{
			$("#remindPanelTb").html("<tr><td align=\"center\">没有申请关注的信息</td></tr>");
		}
	});
}

function openRemindMsg(){
$("#main-panel-2").addClass("hide");
$("#remindPanel").removeClass("hide");
getAttnRemindMsg();
pushHistoryState({url:"c"});//切换页面，存入一个history

}

function getAttnStatus(blogId){
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=getAttnStatus&blogId="+blogId+"&userid="+userid;
	$.get(url, function(responseText){
		var data = $.parseJSON(responseText);
		$("#attnspan").html("");
		$("#attnspan").removeClass("showAttn");
		$("#attnspan").removeClass("showAttnAdd");
		if(data==0){
			$("#attnspan").addClass("showAttn");
			$("#attnspan").html("<span id='attnspan1'>申请关注</span>");
			$("#attnspan1").one('click', function () {
				applyAttention(data,blogId);
			});
		}else if(data==1 || data==2){
			$("#attnspan").addClass("showAttnAdd");
			$("#attnspan").html("<span id='attnspan1'>添加关注</span>");
			$("#attnspan1").one('click', function () {
				addAttention(data,blogId);
			});
		}else if(data==3 || data==4){
			
		}
	});
}

function disAttention(status,blogId){
    var islower=0;
	if(status==4||status==2) islower=1;
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=cancelAttention&islower="+islower+"&blogId="+blogId+"&userid="+userid;
	$.get(url, function(responseText){
		$("#attnspan").html("已取消关注");
	});
	  
}

function applyAttention(status,blogId){
    var islower=0;
	
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=applyAttention&islower="+islower+"&blogId="+blogId+"&userid="+userid;
	$.get(url, function(responseText){
		//var data = $.parseJSON(responseText);
		$("#attnspan").html("已申请关注");
		
	});
	  
}

function addAttention(status,blogId){
    var islower=0;
	if(status==4||status==2) islower=1;
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=addAttention&islower="+islower+"&blogId="+blogId+"&userid="+userid;
	$.get(url, function(responseText){
		$("#attnspan").html("已添加关注");
	});
	     
}

function initScroll(groupid){
	var pullDownObj = document.getElementById('pullDown'+groupid);
	$(pullDownObj).show();
	if(groupid==0){
		pullDownEl = pullDownObj;
	}else if(groupid==1){
		pullDownEl1 = pullDownObj;
	}else if(groupid==2){
		pullDownEl2 = pullDownObj;
	}else if(groupid==3){
		pullDownEl3 = pullDownObj;
	}else if(groupid==4){
		pullDownEl4 = pullDownObj;
	}
	var pullDownOffset = pullDownObj.offsetHeight;
	
	var scrollObj = new IScroll("#"+mainPanelArr[groupid]+" .scroll_wrapper", {
		mouseWheel: true,
		topOffset: pullDownOffset,
		preventDefault: false
	});
	initScrollAft(pullDownObj,scrollObj,groupid);
	
	if(groupid==0){
		mainListScroll = scrollObj;
	}else if(groupid==1){
		mainListScroll1 = scrollObj;
	}else if(groupid==2){
		mainListScroll2 = scrollObj;
	}else if(groupid==3){
		mainListScroll3 = scrollObj;
	}else if(groupid==4){
		mainListScroll4 = scrollObj;
	}
	if(groupid!=3){
		if(groupid==0){
			unTouch("#main-panel");
		}else{
			unTouch("#main-panel-"+groupid);
		}
	}
}

function log(str){
	if(console){
		console.log("log:"+str);
	}
}

function initScrollAft(pullDownObj,scrollObj,groupid){
		scrollObj.on('refresh', function () {
			if (pullDownObj.className.match('loading')) {
				pullDownObj.className = '';
				pullDownObj.querySelector('.pullDownLabel').innerHTML = '下拉可以刷新';
			}
		});
		
		scrollObj.on('scrollStart', function () {
			if(typeof(isBeScrolling) != "undefined"){
				isBeScrolling = true;
			}
		});
		
		scrollObj.on('scrollMove', function () {
			if (this.y > 50 && !pullDownObj.className.match('flip')) {
				pullDownObj.className = 'flip';
				pullDownObj.querySelector('.pullDownLabel').innerHTML = '释放立即刷新';
				this.minScrollY = 0;
			} else if (this.y < 50 && pullDownObj.className.match('flip')) {
				pullDownObj.className = '';
				pullDownObj.querySelector('.pullDownLabel').innerHTML = '下拉可以刷新';
				this.minScrollY = -pullDownOffset;
			}
		});
		
		scrollObj.on('scrollEnd', function () {
			consoleGoTop(groupid);
			if (pullDownObj.className.match('flip')) {
				pullDownObj.className = 'loading';
				pullDownObj.querySelector('.pullDownLabel').innerHTML = '正在刷新...';
				if(groupid==0){
					searchList();
				}else if(groupid<5){
					if(groupid==1){
						pageindex1 = 1;
						$("#main-panel-1 .tab .selected").attr("enddate","").attr("isload","0");
						$("#listpanel1 li").remove();
					}else if(groupid==2){
						$("#main-panel-2 .tab .selected").attr("enddate","").attr("isload","0");
						$("#listpanel2 li").remove();
						pageindex2 = 1;
					}else if(groupid==4){
						$("#main-panel-4 .tab .selected").attr("enddate","").attr("isload","0");
						$("#listpanel4 li").remove();
						pageindex4 = 1;
					}
					searchList1("main-panel-"+groupid);
				}
			}	
		});
	
}

function consoleGoTop(groupid){
	var _top = $(window).height();
	var _top2 = 100;
	if(groupid==0||groupid==1||groupid==4){
		var scrollObj;
		if(groupid==0){
			scrollObj = mainListScroll;
		}else if(groupid==1){
			scrollObj = mainListScroll1;
		}else if(groupid==4){
			scrollObj = mainListScroll4;
		}
		if(scrollObj.y < -(_top)){
			showGotop(groupid);
		}
		if(scrollObj.y >= -(_top2)){
			hideGotop(groupid);
		}
	}
}

function refreshMainListScroll(groupid){
	if(!groupid){
		groupid = 0;
	}
	var scrollObj;
	if(groupid==0){
		 scrollObj = mainListScroll ;
	}else if(groupid==1){
		 scrollObj = mainListScroll1 ;
	}else if(groupid==2){
		 scrollObj = mainListScroll2 ;
	}else if(groupid==3){
		 scrollObj = mainListScroll3 ;
	}else if(groupid==4){
		 scrollObj = mainListScroll4 ;
	}
	if(scrollObj){
		scrollObj.refresh();
	}
}
var pdFn = function(e){
	e.preventDefault();
};
function unTouch(selector){
	var obj = $(selector);
	if(obj.length>0){
		if(obj[0].addEventListener){
			obj[0].addEventListener('touchmove', pdFn, false);
		}else if(obj[0].attachEvent){
			obj[0].attachEvent("ontouchmove", function (e) { e.preventDefault(); });
		}
	}
}

function useTouch(selector){
	var obj = $(selector);
	if(obj.length>0){
		obj[0].removeEventListener("touchmove", pdFn, false);
	}
}

function hasParentClass( e, classname ) {
	if(e === document) return false;
	if($(e).hasClass(classname)) {
		return true;
	}
	return e.parentNode && hasParentClass( e.parentNode, classname );
}

function autoRefreshList(groupid){
	if(groupid==0){
		if(mainListScroll){
			mainListScroll.scrollTo(0,0);
			pullDownEl.className = 'loading';
			pullDownEl.querySelector('.pullDownLabel').innerHTML = '正在刷新...';
		}
		searchList();	
	}else if(groupid==1){
		if(mainListScroll1){
			mainListScroll1.scrollTo(0,0);
			pullDownEl1.className = 'loading';
			pullDownEl1.querySelector('.pullDownLabel').innerHTML = '正在刷新...';
		}
		searchList1("main-panel-1");
	}
}

function loadListByPageLoad(groupid){
	var key ;
	var selectli;
	if(groupid==0){
		key = itemKey;
	}else if(groupid==1){
		selectli = $("#main-panel-1 ul.tab li.selected");
		var ctype = selectli.attr("ctype");
		$("#listpanel1").attr("currentType",ctype);
		selectli.attr("endDate","").attr("isload",0);
		key = itemKey+"_"+ctype;
	}
	if(!key){
		return;
	}
	var mainListData = localStorage.getItem(key);
	if(mainListData != null){
		mainListData = JSON.parse(mainListData);
		var _userid = mainListData["userid"];
		if(_userid == userid){
			var data = mainListData["data"];
			if(groupid==0){
				buildList(data,mec_id,0);
			}else{
				var theid =  "panel"+groupid;
				buildList(data,theid,groupid,selectli);
			}
			var timestmp = mainListData["timestmp"];
			var nowTimestmp = new Date().getTime();
			var timeout = 1000 * 60 * 60 * 2;	//2小时
			var between = nowTimestmp - timestmp;
			if(between > timeout){
				if(selectli){
					selectli.attr("endDate","").attr("isload",0);
				}
				autoRefreshList(groupid);
			}
		}else{	//用户改变了，重新缓存数据
			refreshList(groupid);
		}
	}else{
		refreshList(groupid);
	}
	if(groupid>0){
		selectli.attr("isload",1);
	}
}

function refreshList(groupid){
	if(groupid==0){
		$("#list" + mec_id).find("*").remove();
		$("#more" + mec_id).hide();
		$("#nodata" + mec_id).hide();
		refreshMainListScroll();
		$("#NMEC_" + mec_id + " .mec_refresh_loading").show();
		pageindex = 1;
		searchList();
	}else if(groupid==1){
		var tid = "panel"+groupid;
		$("#list" + tid).find("*").remove();
		$("#more" + tid).hide();
		$("#nodata" + tid).hide();
		refreshMainListScroll(groupid);
		$("#NMEC_" + tid + " .mec_refresh_loading").show();
		pageindex1 = 1;
		searchList1("main-panel-1");
	}
}

function pageList(groupid){
	var theid = mec_id;
	if(groupid>1){
		theid = "panel"+groupid;
	}
	$("#more" + mec_id).hide();
	$("#NMEC_" + mec_id + " .mec_refresh_loading").show();
	if(groupid==0){
		pageindex++;
		searchList();
	}else if(groupid==1){
		pageindex1++;
		searchList1("main-panel-1");
	}else if(groupid==2){
		
	}else if(groupid==3){
		
	}else if(groupid==4){
		pageindex4++;
		searchList1("main-panel-4");
	}
}

var pageindex = 1;
var pagesize = 20;
/**
 * 
 * @param {Object} isRefreshFirstPageData  用来后台刷新第一页的数据
 */
function searchList(isRefreshFirstPageData){
	var keyword = $(".searchKey").val();
	var $tabItem = $(".tab > li.selected");
	var labelid = $tabItem.attr("labelid")
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=homepage&pageindex="+pageindex+"&pagesize="+pagesize+"&userid="+userid;
	if(isRefreshFirstPageData){
		url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=homepage&pageindex=1&pagesize="+pagesize+"&userid="+userid;
	}
	$.get(url, function(responseText){
		if(!isRefreshFirstPageData){
			var $mecContainer = $("#NMEC_" + mec_id);
			var $loading = $(".mec_refresh_loading", $mecContainer);
			$loading.hide();
		}
		var data = $.parseJSON(responseText);
		var $ul = $("#list" + mec_id);
		if(pageindex == 1||isRefreshFirstPageData){
			if(!isRefreshFirstPageData){
				$ul.find("*").remove();
			}
			if($tabItem.index() == 0||isRefreshFirstPageData){
				var mainListData = {};
				mainListData["timestmp"] = new Date().getTime();
				mainListData["data"] = data;
				mainListData["userid"] = userid;
				localStorage.removeItem(itemKey);
				localStorage.setItem(itemKey, JSON.stringify(mainListData));
			}
		}
		if(!isRefreshFirstPageData){
			buildList(data,mec_id,0);
		}
	});
}

var locationArr = new Array();
var allIndex = 1;
/**
 * 
 * @param {Object} data
 * @param {Object} theid
 */
function buildList(data,theid,groupid,selectli){
	var datas = data["datas"];
	var $ul = $("#list" + theid);
	
	var pindex = 0;
	if(groupid==1){
		pindex = pageindex1;
	}else if(groupid==2){
		pindex = pageindex2;
	}
	if(pindex==1){
		$("#list" + theid+" li").remove();
	}
	var isBuildGzList = false;
	if(groupid==4){
		var typeLi = $("#main-panel-4 .tbar > li.selected");
		var type = typeLi.attr("type");
		if(type=="wb"){//微博
			$("#blogCount").html(data["blogCount"]);
			$("#myAttentionCount").html(data["myAttentionCount"]);
			$("#attentionMeCount").html(data["attentionMeCount"]);
		}else if(type=="gz"){//关注
			isBuildGzList = true;
		}else if(type=="fs"){//粉丝
			isBuildGzList = true;
		}
	}else if(groupid==1){
		if(selectli.attr("ctype")=="myblog"){
			$("#blogCountSpan").html("("+data["blogCount"]+")");
		}
	}else if(groupid==2){
		$("#myAttentionSpan").html("("+data["myAttentionCount"]+")");
		$("#attentionMeSpan").html("("+data["attentionMeCount"]+")");
	}
	
	for(var i = 0; i < datas.length; i++){
		var da = datas[i];
		var id = "";
		var username = da["username"];
		var discussuserid = da["discussuserid"];
		var userimg = da["userimg"];
		var jbotitle = da["jbotitle"];
		var deptname = da["deptname"];
		if(deptname!=""){
			jbotitle = deptname+ " "+jbotitle;
		}
		if(jbotitle==""){jbotitle="&nbsp;";}
		var moodIcon = da["moodIcon"];
		var isreplenish = da["isreplenish"];
		var createdate = da["createdate"];
		var createtime = da["createtime"];
		var contents = da["contents"];
		var workdate = da["workdate"];
		var subline = "";
		var bjstr = "";
		var dateHtml = "";
		if(groupid==0){
			subline = da["subline"];
			bjstr = da["bjstr"]
		}else if((groupid==1||groupid==4)&&!isBuildGzList){
			dateHtml+= "<div class=\"dateRowWrap\">"
						 +"<div class=\"weekdaydiv\">"+da["weekday"]+"</div>"
						 +"<div class=\"datediv\">"+da["worddateMD"]+"</div>"
					  +"</div>";
			if(selectli){
				selectli.attr("endDate",da["_endDate"]);
			}
		}
		
		var replycomments = da["replycomments"];
		
		var liid = "";
		var html = "";
		if((groupid==0||groupid==1||groupid==4)&&!isBuildGzList){
			var workdateCal = da["workdateCal"];
			var weekdayCal = da["weekdayCal"];
			id = da["discussid"];
			liid ="li_"+groupid+"_"+allIndex++;
			
			var haslocation = da["haslocation"];
			var locationHTML = "";
			if(haslocation==1){
				locationHTML = "";
				var loc = da["location"];
				var location = loc["location"];
				var locationName = loc["locationName"];
				var locationData = da["locationData"];
				if(!locationData){
					localStorage.removeItem("mobilemode_blog_mainList_data");
					localStorage.removeItem("mobilemode_blog_mainList_data_myblog");
					localStorage.removeItem("mobilemode_blog_mainList_data_commentOnMe");
					autoRefreshList(groupid);
					return;
				}
				locationArr.push(locationData);
				var index = locationArr.length;
				var arr = location.split(",");
				if(locationName==""){
					locationName = "地图查看";
				}
				if(locationData.length>1){
					locationName = "地图查看";
				}
				locationHTML = "<div class=\"locationDiv\" onclick=\"openMap("+index+");\"><div class=\"locationText\">"+locationName+"</div></div>";
			}

			html = "<li id=\""+liid+"\" disid=\""+id+"\"  workdate=\""+workdate+"\" username=\""+username+"\" userid=\""+discussuserid+"\" groupid=\""+groupid+"\" >";
			html+= "	<div class='seprator'>"+subline+"</div>";
			html+= "	<div class='blogContent'>"
				 + "		<div class='blogCalendar'><div>"+workdateCal+"</div><div>"+weekdayCal+"</div></div>"
			html+= "		<img src='"+userimg+"'/>";
			html+= "		<div><a>"+username+"</a></div>";
			html+= "		<div class='desc'>"+jbotitle+"</div>";
			html+= "	</div>";
			html+= "	<div class='content'>"+bjstr+contents+locationHTML+"</div>";
			html+= "	<div class='footer'>";
			html+= "		<span class='desc'>"+createdate+" "+createtime+"</span>";
			html+= "		<div class='btn'>";
			if(groupid==1){
				var mdStr = "";
				var worddateMD = da["worddateMD"];
				if(worddateMD){
					mdStr = worddateMD;
				}
				var isshowBj = da["isshowBj"];
				if(isshowBj&&isshowBj==1&&weekdayCal!="今天"){
					html+= "<button class=\"bjBtn\" onclick=\"javascript:createBlog(4,'"+liid+"','"+groupid+"','"+mdStr+"')\">补交</button>";
				}
				var isshowBianJi = da["isshowBianJi"];
				if(isshowBianJi&&isshowBianJi==1){
					html+= "<button class=\"bjBtn\" onclick=\"javascript:createBlog(5,'"+liid+"','"+groupid+"','"+mdStr+"','"+encodeURIComponent(contents)+"')\">编辑</button>";
				}
			}
			html+= "			<button onclick=\"javascript:createBlog(2,'"+liid+"','"+groupid+"')\">评论</button>";
			html+= "			<button onclick=\"javascript:createBlog(3,'"+liid+"','"+groupid+"')\">私评</button>";
			html+= "		</div>";
			html+= "	</div>";
			html+= replycomments;
			html+= "</li>";

		}else if(groupid==2||isBuildGzList){
			var ctype = selectli.attr("ctype");
			var clickStr = "";
			id = da["id"];
			if(ctype=="myAttention"){//我的关注
				clickStr = "openBlog("+id+");";
			}
			var islower = da["islower"];
			var workIndex = da["workIndex"];
			var workIndexClass = da["workIndexClass"];
			html = "<li id=\"li_"+groupid+"_"+id+"\" username=\""+username+"\" userimg=\""+userimg+"\" jbotitle=\""+jbotitle+"\" onclick=\""+clickStr+"\" >"
					+ "<table>"
						+ "<tbody>"
							+ "<tr class=\"contenttr\">"
								+ "<td class=\"fieldPart\">"
									+ "<div class=\"titleRowWrap\">"
										+ "<div class='jobIndex'>工作指数<br/><div title='"+workIndex+"' class='pBarContainer"+workIndexClass+"'></div></div>"
										+ "<img src=\""+userimg+"\">"
										+ "<span>"+username+"</span>"
									+ "</div>"
									+ "<div class=\"rowWrap\">"
										+ "<div class=\"colWrap\"><span>" + jbotitle + "</span></div> " 
									+ "</div>"
								+ "</td>"
							+ "</tr>"
						+ "</tbody>"
					+ "</table>";
					
					var slideHTML = "";
					if(ctype=="myAttention"){//我的关注
						var status = da["status"];
						var type = "";
						if(status==0){
							type="apply"
						}else if(status==1){
							type = "add";
						}else if(status==2){
							type = "cancel"
						}
						slideHTML="<div class=\"slideBtnContainer\">"
									+"<div class=\"btnContainer2\">"
										+"<div class=\"btnBox\" id=\"cancelBtn_"+id+"\" status=\""+type+"\" onclick=\"changeAttention(this,"+id+","+islower+",event)\">取消关注</div>"
									+"</div>"
								+"</div>";
					}else if(ctype=="attentionMe"){
						var status = da["status"];
						var islower = da["islower"];
						var btnText = "";
						var type = "";
						if(status==0){
							type = "apply";
							btnText = "申请关注";
						}else if(status==1||status==2){
							type = "add";
							btnText = "添加关注";
						}else if(status==3||status==4){
							type = "cancel";
							btnText = "取消关注";
						}
						slideHTML="<div class=\"slideBtnContainer\">"
									+"<div class=\"btnContainer2\">"
										+"<div class=\"btnBox\" id=\"cancelBtn_"+id+"\" status=\""+type+"\" onclick=\"changeAttention(this,"+id+","+islower+",event)\">"+btnText+"</div>"
									+"</div>"
								+"</div>";
					}
					
					html+= slideHTML
				+ "</li>";
		}
		$ul.append(html);
	}
	if(groupid==2){
		swipeListData("panel2");//添加滑动事件
	}
	var totalSize = parseInt(data["totalSize"]);
	var totalPageCount = parseInt((totalSize + pagesize - 1) / pagesize);
	var $moreBtn = $("#more" + theid);
	var p =  pageindex;
	if(groupid==1){
		p = pageindex1;
	}else if(groupid==2){
		p = pageindex2;
	}else if(groupid==3){
		p = pageindex3;
	}else if(groupid==4){
		p = pageindex4;
	}
	if(p >= totalPageCount){
		$moreBtn.hide();
	}else{
		$moreBtn.show();
	}
	if(groupid==2){
		$moreBtn.hide();
	}else if(groupid==4){
		var typeLi = $("#main-panel-4 .tbar > li.selected");
		var type = typeLi.attr("type");
		if(type=="gz"){//关注
			$moreBtn.hide();
		}else if(type=="fs"){//粉丝
			$moreBtn.hide();
		}
	}
	var $nodata = $("#nodata" + theid);
	if(totalSize == 0){
		$nodata.show();
	}else{
		$nodata.hide();
	}
	refreshScrollWithImg(groupid);
	//pc端发表模板微博，手机端展示不全且没有滚动条问题
	if(groupid==0||groupid==1||groupid==4){
		setTimeout(function(){
			$ul.find("table").each(function(){
				//$(this).css({
				//		"width":"100%",
				//		"word-wrap":"break-word",
				//		"word-break":"break-all"
				//	});
				//console.log('11111:',document.body.clientWidth,$(this).width());
				
				$(this).find("span").each(function(){
					$(this).css({
						"white-space":"normal"
					});
				});
				
				if($(this).width() > document.body.clientWidth-10){
					//console.log('content:',$(this).parents(".content").attr("id"));
					new IScroll($(this).parents(".content").get(0), {
						 scrollX: true, scrollY: false, mouseWheel: true
					});
				}
			});
		}, 500);
	}
}

/**
 * 当内容中有图片时，刷新2次,否则iscroll会出现滚动不到底部的现象
 */
function refreshScrollWithImg(groupid){
	refreshMainListScroll(groupid);
	setTimeout(function(){
		refreshMainListScroll(groupid);
	}, 2000);
}

function swipeListData(id){
	var $list = $("#list"+id).filter("[swipe='true']");
	if($list.length > 0){
		var type = $list.attr("swipeType");
		if(!type || type == ""){
			type = "1";
		}
		$list.children("li").each(function(){
			var $li = $(this);
			if($li.attr('swipe_event') != "true"){
				
				var bodyTouch = util.toucher($li[0]);
				
				bodyTouch.on('swipeLeft',function(e){
					
					var $theLi = $(this);
					
					var pdFn = function(e){
						e.preventDefault();
					};
					
					$theLi[0].addEventListener('touchmove', pdFn, false);
					setTimeout(function(){
						$theLi[0].removeEventListener("touchmove", pdFn, false);
					}, 300);
					
					
					//向左滑动时先复原其他已被划出的LI
					$theLi.siblings("[is_swiped='true']").trigger("swipeRight");
					
					var $slideBtnContainer = $(".slideBtnContainer", $theLi);
					var w = $slideBtnContainer.width();
					
					var $table = $theLi.children("table");
					if(type == "1"){
						$table.css({
							"-webkit-transform" : "translate3d(-"+w+"px, 0, 0)",
							"transform" : "translate3d(-"+w+"px, 0, 0)"
						});
						$slideBtnContainer.addClass("show");
					}else if(type == "2"){
						$slideBtnContainer.addClass("show");
					}
					$theLi.attr("is_swiped", "true");
					
					
					
				});
				
				var rightFn = function(e){
					var $theLi = $(this);
					
					var pdFn = function(e){
						e.preventDefault();
					};
					
					$theLi[0].addEventListener('touchmove', pdFn, false);
					setTimeout(function(){
						$theLi[0].removeEventListener("touchmove", pdFn, false);
					}, 300);
					
					var $slideBtnContainer = $(".slideBtnContainer", $theLi);
					var $table = $theLi.children("table");
					var w = $slideBtnContainer.width();
					
					if(type == "1"){
						$slideBtnContainer.removeClass("show");
						$table.css({
							"-webkit-transform" : "translate3d(0, 0, 0)",
							"transform" : "translate3d(0, 0, 0)"
						});
					}else if(type == "2"){
						$slideBtnContainer.removeClass("show");
					}
					$theLi.removeAttr("is_swiped");
				};
				
				bodyTouch.on('swipeRight', rightFn);
				$li.on('swipeRight', rightFn)
			}
		});
		
		$list.children("li").attr("swipe_event", "true");
	}
};


function detailPanelIsShow(){
	return 	$("#main-panel").hasClass("hide") && (!$("#detail-panel").hasClass("hide"));
}

function showDetailPanel(){
	showPanel("detail-panel");
	hidePanel("main-panel");
}

function hideDetailPanel(){
	showPanel("main-panel");
	hidePanel("detail-panel");
}

function hideDetailPanel1(eve){
	hideDetailPanel();
	eve.stopPropagation();
}

function downloads(fileid,obj,filename){
   	filename=filename?filename:"";
	location = "/download.do?fileid="+fileid+"&filename="+encodeURI(filename)+"&module=-2&scope=-301";
}

Mobile_NS.TabBarCustom = {};
var indexTab = 0;
Mobile_NS.TabBarCustom.onload = function(p) {
    var id = p.id;
    var tBar = this;
    var $container = $("#NMEC_" + id);
    $(".tab-item", $container).click(function(e) {
       	controlTab(this,p,tBar);
    })
};

function controlTab(obj,p,tBar){
	var index = $(obj).index();
	if(index!=3){
		$("#NMEC_panel3 .fixedGtWrap").css("left","-1100px");
	}else{
		$("#NMEC_panel3 .fixedGtWrap").css("left","0px");
	}
	if (!$(obj).hasClass("active")) {
        $(obj).siblings(".tab-item.active").removeClass("active");
        $(obj).addClass("active");
        var itemId = $(obj).attr("id");
        var data = tBar.getDataById(p, itemId);
        var targetpanel = data.targetpanel;
        
        var currentPanel =$(".currentPanel");
        var currentid = currentPanel.attr("id");

        /* hubo, 2016/3/14*/
        indexTab = index;
        changeListContainerPosition(indexTab);
        var tempid = currentid;
    	for(var i=0;i<mainPanelArr.length;i++){
    		if(index==i){
    			currentid = mainPanelArr[i];
		        hidePanel(tempid);
    			showPanel(currentid);
    			break;
    		}
    	}
    	var selectli = $("#"+currentid +" ul.tab li.selected");
    	var groupid = selectli.attr("groupid");
    	if(groupid>0){
    		var isload = selectli.attr("isload");
    		if(typeof(isload)!="undefined"&&isload!=1){//未加载
    			if(groupid==1){
	    			loadListByPageLoad(1);
    			}else if(groupid==2){
    				searchList1(currentid);
    				getAttnRemindNum();
    			}else{
    				searchList1(currentid);
    			}
    		}
        	refreshScrollWithImg(groupid)
    	}else{
    		
    	}
    }
    //把所有其他的panel都隐藏
	if(!$("#mapPanel").hasClass("hide")){
		$("#mapPanel").addClass("hide");
		doHistoryBack();
	}
	if(!$("#replayPanel").hasClass("hide")){
		$("#replayPanel").addClass("hide");
		if($("#main-panel-4").hasClass("hideCurrent")){
			$("#main-panel-4").removeClass("hideCurrent");
		}
		doHistoryBack();
	}
	if(!$("#remindPanel").hasClass("hide")){
		$("#remindPanel").addClass("hide");
		doHistoryBack();
	}
    if(!$("#main-panel-4").hasClass("hide")){
		$("#main-panel-4").addClass("hide");
		doHistoryBack();
	}
    setTimeout(function(){
    	controlLastShow();
    },100);
    setTimeout(function(){
    	controlLastShow();
    },200);
    setTimeout(function(){
    	controlLastShow();
    },300);
}

function controlLastShow(){
	if($(".currentPanel").hasClass("hide")){
    	$(".currentPanel").removeClass("hide")
    }
}

Mobile_NS.TabBarCustom.getDataById = function(d, e) {
    var b = d.datas;
    for (var c = 0; c < b.length; c++) {
        var a = b[c]["id"];
        if (a == e) {
            return b[c]
        }
    }
    return null
};

/**
 * 隐藏panel，从左侧滑出且把它放到屏幕最右边
 * @param {Object} objid
 * @param flag 是否切换到其他主panel
 */
function hidePanel(objid){
	$("#"+objid).addClass("hide2").removeClass("currentPanel");
    setTimeout(function(){
	    setTimeout(function(){
	    	$("#"+objid).removeClass("hide2").addClass("hide");
	    },50);
    },300);
}

function showPanel(objid){
	$("#"+objid).removeClass("hide").addClass("currentPanel");
}

var mainPanelArr = ["main-panel","main-panel-1","main-panel-2","main-panel-3","main-panel-4"];
$(document).ready(function(){
	Mobile_NS.TabBarCustom.onload({
		"id" : "C6F99F2AC7E00001D7347D1011C0F560",
		"datas" : [ {
			"id" : "C6F99F2AC7E00001F06318A0A4F01729",
			"targetpanel" : mainPanelArr[0],
		}, {
			"id" : "C6F99F53B8200001D83DD140AAC01E52",
			"targetpanel" : mainPanelArr[1],
		}, {
			"id" : "C6F99F68D350000190D711307D801AB7",
			"targetpanel" : mainPanelArr[2],
		}, {
			"id" : "C6F99F68D350000190D711307D801AC6",
			"targetpanel" : mainPanelArr[3],
		}]
	});
});


var pageindex1 = 1;
var pagesize1 = 20;

var pageindex2 = 1;
var pagesize2 = 20;

var pageindex3 = 1;
var pagesize3 = 20;

var pageindex4 = 1;
var pagesize4 = 20;

var lastBlogid;
function searchList1(currentid,isRefreshFirstPageData,flag){
	var selectli = $("#"+currentid +" ul.tab li.selected");
	var ctype = selectli.attr("ctype");
	if(flag == 1){
		ctype = "myblog";
	}
	var endDate = selectli.attr("endDate");
	var isload = selectli.attr("isload");
	if(endDate==null){
		endDate = "";
	}
	$("#"+currentid +" ul.tab li:not(.selected)").attr("endDate","");
	$("#"+currentid +" ul.tab li:not(.selected)").attr("isload","0");
	
	var groupid = selectli.attr("groupid");
	if(groupid==2){
		$("#listpanel2 li").remove();
	}
	var typeLi = $("#main-panel-4 .tbar > li.selected");
	var type = typeLi.attr("type")
	if(groupid==4){
		if(type=="gz"){//关注
			$("#listpanel4 li").remove();
		}else if(type=="fs"){//粉丝
			$("#listpanel4 li").remove();
		}
	}
	var theid =  "panel"+groupid;
	var $mecContainer = $("#NMEC_" + theid);
	var $loading = $(".mec_refresh_loading", $mecContainer);
	$("#more"+theid).hide();
	$("#nodata"+theid).hide();
	var currentType = $("#list"+theid).attr("currentType");
	if(!isRefreshFirstPageData){
		if(groupid!=3){
			if(typeof(currentType)=="undefined"||currentType!=ctype){
				$("#list"+theid).html("");
			}
		}
		if(isload!=null&&isload==1){
			$loading.show();
			if(groupid==3){
				$("#"+ctype+"_div").hide();
			}
		}else{
			if(isload==null){
				$loading.show();
			}
			if(groupid==1){
				mainListScroll1.scrollTo(0,0);
			}else if(groupid==2){
				mainListScroll2.scrollTo(0,0);
			}else if(groupid==3){//未加载过
				$(".monthTable .selected").removeClass("selected");
				var monthTable = $(".monthTable");
				var currentmonth = monthTable.attr("currentmonth");
				$($(".searchMonth")[currentmonth-1]).addClass("selected");
			}else if(groupid==4){
				mainListScroll4.scrollTo(0,0);
			}
			$("#pullDown"+groupid).addClass("loading").show();
			$("#pullDown"+groupid+" .pullDownLabel").html("正在刷新...");
		}
	}
	var index = pageindex;
	var size = pagesize;
	if(groupid==1){
		index = pageindex1;
		size = pagesize1;
	}else if(groupid==2){
		index = pageindex2;
		size = pagesize2;
	}else if(groupid==3){
		index = pageindex3;
		size = pagesize3;
	}else if(groupid==4){
		index = pageindex4;
		size = pagesize4;
	}
	if(isRefreshFirstPageData){
		index = 1;
		endDate = "";
	}
	var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation="+ctype+"&pageindex="+index+"&pagesize="+size+"&endDate="+endDate+"&userid="+userid;
	if(groupid==2){
		url += "&keyword="+$("#keyword").val();
	}
	if(groupid==4){
		var blogid = selectli.attr("blogid");
		if(type=="wb"){//微博
			if(!lastBlogid){
				lastBlogid = blogid; 
			}
			if(!lastBlogid||(lastBlogid!=blogid)){
				lastBlogid = blogid;
				$("#blogCount").html("...");
				$("#myAttentionCount").html("...");
				$("#attentionMeCount").html("...");
			}
		}else if(type=="gz"){//关注
			url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=myAttention&pageindex="+index+"&pagesize="+size+"&endDate="+endDate+"&userid="+userid;
			url += "&keyword="+$("#keyword4").val();
		}else if(type=="fs"){//粉丝
			url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=attentionMe&pageindex="+index+"&pagesize="+size+"&endDate="+endDate+"&userid="+userid;
			url += "&keyword="+$("#keyword4").val();
		}
		
		url += "&blogid="+blogid;
	}
	var containerSel = ".GridTableContainer";
	if(groupid==3){
		var h = $("#main-panel-3")[0].clientHeight
				-$("#scroll_footer")[0].clientHeight
				-$("#main-panel-3 .header")[0].clientHeight
				-29-10;
				//-$("#gtsearchC6FB923056600001AE39160C15209800")[0].clientHeight-10;
		if(isload!=null&&isload==1){
			containerSel = "#"+ctype+"_div .gtWrap";
		}
		
		$(".gtSearch").addClass("gtSearch_boder");
		$loading.show();
		url += "&month="+$(".monthTable div.selected").attr("data-value");
		$("#list"+theid+" "+containerSel+"").hide();
	}
	
	$.get(url, function(responseText){
		var data = $.parseJSON(responseText);
		if(groupid!=3){
			if(!isRefreshFirstPageData){
				buildList(data,theid,groupid,selectli);
				$loading.hide();
			}
			if((groupid==1&&pageindex1==1)||isRefreshFirstPageData){
				var key = itemKey+"_"+ctype;
				var mainListData = {};
				mainListData["timestmp"] = new Date().getTime();
				mainListData["data"] = data;
				mainListData["userid"] = userid;
				localStorage.removeItem(key);
				localStorage.setItem(key, JSON.stringify(mainListData));
			}
		}else{
			$(".fixedGtContentWrapMapping").find("*").remove();
			buildListReport(data,theid,groupid,selectli,ctype);
			if(ctype=="myReport"){
				$("#myReport_div").css("height",h+"px");
				$("#myReport_div").show();
				$("#myAttentionReport_div").hide();
			}else{
				$("#myAttentionReport_div").css("height",h+"px");
				$("#myAttentionReport_div").show();
				$("#myReport_div").hide();
			}
			$(".gtSearch").removeClass("gtSearch_boder");
			$loading.hide();
			
			
			$("#list"+theid+" "+containerSel+"").show();
			setTimeout(function(){
				var monthTab = $(".monthTable");
				var pdiv = monthTab.parent();
				var pdiv1 = pdiv.parent();
				var h0 = $(".monthTable").height();
				if(h0>0){
					pdiv.css("height",h0+"px");
					pdiv1.css("height",h0+"px");
				}
			},100);
			if(ctype=="myAttentionReport"){
				var col = $("#"+ctype+"_div .gtWrap .complate td");
				var allW = col.length*30;
			}else{
				var col = $("#"+ctype+"_div .gtWrap .trindex1 td");
				var allW = col.length*30;
				$("#"+ctype+"_div .gtContentWrap").css("width",allW+"px");
			}
			
			var leftTabWidth = $(".fixedGtWrap")[0].clientWidth;
			var iswidth = $("#"+ctype+"_div .gtWrap").attr("iswidth");
			if(iswidth==null||iswidth!=1){
				var w = $("#"+ctype+"_div .gtTitle")[0].clientWidth+1;
				$("#"+ctype+"_div .gtContentWrap").css("width",w+"px");
				$("#"+ctype+"_div .gtContentWrap").attr("iswidth",1);
			}
			var firstRowHeight = $("#"+ctype+"_div .fixedGtTitleWrap")[0].clientHeight;
			var h2 = h-firstRowHeight;
			$("#"+ctype+"_div .gtContentWrap").css("height",h2+"px");
			$("#"+ctype+"_div .fixedGtContentWrap").css("height",h2+"px");
			asyncScroll(ctype+"_div");
		}
		$("#"+currentid +" ul.tab li").attr("isload","0");
		$("#"+currentid +" ul.tab li.selected").attr("isload","1");
		$("#list"+theid).attr("currentType",ctype);
	});
}

function writelog(str){
	if(console){
		console.log("log:"+str);
	}
}

/**
 * 同步上下滚动
 * @param {Object} id
 * @memberOf {TypeName} 
 * @return {TypeName} 
 */
function asyncScroll(id){
	var $container = $("#"+id);
	$(".gtWrap", $container).scrollLeft(0);
	$(".fixedGtContentWrap", $container).css("visibility", "visible").show();
	$(".fixedGtContentWrapMapping", $container).hide().css("left","0px");
	var rightTimeoutId = null;
	var rightScrolling = false;
	$(".gtContentWrap", $container).on("scroll", function(){
		if(leftScrolling || verticalScrolling){
			return;
		}
		rightScrolling = true;
		if(rightTimeoutId){
			clearTimeout(rightTimeoutId);
		}
		$(".fixedGtContentWrapMapping", $container).show();
		$(".fixedGtContentWrap", $container).css("visibility", "hidden").hide();
		$(".fixedGtContentWrap", $container).scrollTop($(this).scrollTop());
		
		
		rightTimeoutId = setTimeout(function(){
			rightScrolling = false;
		}, 100);
	});
	
	var leftScrolling = false;
	var leftTimeoutId = null;
	$(".fixedGtContentWrap", $container).on("scroll", function(){
		if(rightScrolling  || verticalScrolling){
			return;
		}
		
		leftScrolling = true;
		if(leftTimeoutId){
			clearTimeout(leftTimeoutId);
		}
		
		$(".fixedGtContentWrapMapping", $container).show();
		$(this).css("visibility", "hidden").hide();
		$(".gtContentWrap", $container).scrollTop($(this).scrollTop());
		
		leftTimeoutId = setTimeout(function(){
			leftScrolling = false;
		}, 100);
	});
	
	var verticalScrolling = false;
	var verticalTimeoutId = null;
	$(".gtWrap", $container).on("scroll", function(){
		verticalScrolling = true;
		
		if(verticalTimeoutId){
			clearTimeout(verticalTimeoutId);
		}
		$(".fixedGtContentWrap", $container).css("visibility", "visible").show();
		$(".fixedGtContentWrap", $container).scrollTop($(".gtContentWrap", $container).scrollTop());
		$(".fixedGtContentWrapMapping", $container).hide().css("left", $(this).scrollLeft() + "px");
		verticalTimeoutId = setTimeout(function(){
			verticalScrolling = false;
		}, 100);
	});
	
	
	var $gtContent = $("#"+id+" .fixedGtWrap .fixedGtContentWrap .gtContent");
	var $cloneGtContent2 = $gtContent.clone();
	$(".fixedGtContentWrapMapping", $container).find("*").remove();
	$(".fixedGtContentWrapMapping", $container).append($cloneGtContent2);
	$(".fixedGtContentWrapMapping", $container).css("width",$("#"+id+" .fixedGtWrap")[0].clientWidth+"px");
	
}

var myAttentionReportScroll;
var myReportScroll;
function initContentScroll(objid){
	if(objid=="myAttentionReport_div"){
		if(!myAttentionReportScroll){
			myAttentionReportScroll = new IScroll("#"+objid, {
				mouseWheel: true,
				preventDefault: false
			});
		}else{
			myAttentionReportScroll.refresh();
		}
	}else{
		if(!myReportScroll){
			myReportScroll = new IScroll("#"+objid, {
				mouseWheel: true,
				preventDefault: false
			});
		}else{
			myReportScroll.refresh();
		}
	}
}


/**
 * 构造微博报表
 * @param {Object} data
 * @param {Object} theid
 * @param {Object} groupid
 * @param {Object} selectli
 */
function buildListReport(data,theid,groupid,selectli,ctype){
	if(ctype=="myReport"){//我的报表
		var baseUrl = "/mobilemode/apps/e-cology/blog/imgs/";
		var totaldateList = data["totaldateList"];//总天数
		var ismood = data["ismood"];//是否启用心情
		var moodReportList = data["moodReportList"];
		var isSignInOrSignOut = data["isSignInOrSignOut"];//是否启用签到
		var scheduleReportList = data["scheduleReportList"];
		var reportList = data["reportList"];//微博报表
		var $ul = $("#list" + theid);
		var reportday = $("#"+ctype+"_div .gtTitle tr:nth-child(1) .reportday");
		var reportvalue = $("#"+ctype+"_div .gtContent tr:nth-child(1) .reportvalue");
		var colNum = reportday.length;//当前列数
		var dataNum = totaldateList.length;//工作日天数
		var gtTitleTr = $("#"+ctype+"_div .gtTitle tr.complate");//标题tr
		var content_tr = $("#"+ctype+"_div .gtContentWrap .content_tr");//内容tr
		
		var contenttr = $("#"+ctype+"_div .gtContentWrap tr:not(.complate)");
		var fixtr = $("#"+ctype+"_div .fixedGtContentWrap tr:not(.complate)");
		contenttr.remove();
		fixtr.remove();
		
		if(colNum<dataNum){//需要加列
			for(var i=0;i<dataNum-colNum;i++){
				gtTitleTr.append("<td class=\"reportday\"></td>");
			}
		
			for(var i=0;i<content_tr.length;i++){
				for(var j=0;j<dataNum-colNum;j++){
					$(content_tr[i]).append("<td class=\"reportvalue\"><span class=\"field_viewText\"></span></td>");
				}
			}
		}else if(colNum>dataNum){//需要删除列
			for(var i=0;i<colNum-dataNum;i++){
				$(reportday[colNum-i-1]).remove();
			}
			
			for(var i=0;i<colNum-dataNum;i++){
				$(reportvalue[colNum-i-1]).remove();
			}
		}
		
		
		var count = 1;
		if(isSignInOrSignOut==1){
			count ++;
		}
		if(ismood){
			count ++;
		}
		
		$("#"+ctype+"_div .reportday").html("");
		$("#"+ctype+"_div .reportvalue .field_viewText").html("");
		reportday = $("#"+ctype+"_div .reportday");
		
		var leftTabTr = 	$("#"+ctype+"_div .fixedGtContentWrap tr.complate");//左侧区域
		var rightTabTr = $("#"+ctype+"_div .gtContentWrap tr.complate");//右侧区域
		for(var i=0;i<count-1;i++){
			var tr = leftTabTr.clone();
			$("#"+ctype+"_div .fixedGtContentWrap .gtContent").append(tr);
			tr.removeClass("complate");
			
			var tr1 = rightTabTr.clone();
			$("#"+ctype+"_div .gtContentWrap .gtContent").append(tr1);
			tr1.removeClass("complate");
		}
		
		for(var i=0;i<totaldateList.length;i++){
			$(reportday[i]).html(totaldateList[i]);
		}
		
		var titleText = $("#"+ctype+"_div .fixedGtContentWrap .field_viewText");
		var len = titleText.length;
		$(titleText[0]).html("微博报表");
		if(isSignInOrSignOut==1){
			count ++;
			if(len==2){
				$(titleText[1]).html("考勤报表");
			}else if(len==3){
				$(titleText[2]).html("考勤报表");
			}
		}
		if(ismood){
			count ++;
			if(len>=2){
				$(titleText[1]).html("心情报表");
			}
		}
		
		var signNo = baseUrl+"sign-no_wev8.png";
		var signAbsent = baseUrl+"sign-absent_wev8.png";
		var signOk = baseUrl+"sign-ok_wev8.png";
		var index = 0;
		
		var wbspan = $("#"+ctype+"_div .gtContent tr:nth-child(1) .reportvalue .field_viewText");//微博报表
		var xqspan;
		var kqspan;
		if(ismood && isSignInOrSignOut==1){
			xqspan = $("#"+ctype+"_div .gtContent tr:nth-child(2) .reportvalue .field_viewText");//心情报表
			kqspan= $("#"+ctype+"_div .gtContent tr:nth-child(3) .reportvalue .field_viewText");//考勤报表
		}else if(!ismood && isSignInOrSignOut==1){
			kqspan= $("#"+ctype+"_div .gtContent tr:nth-child(2) .reportvalue .field_viewText");//考勤报表
		}
		
		 
		for(var i=0;i<reportList.length;i++){
			var isWorkday = reportList[i]["isWorkday"];
			if(isWorkday){
				var isSubmited = reportList[i]["isSubmited"];
				var submitHtml = "";
				if(isSubmited){
					submitHtml = "<div class='submitOk'>";
				}else{
					submitHtml = "<div class='submitNo'>";
				}
				$(wbspan[index]).html(submitHtml);
				if(ismood){
					var faceImg = moodReportList[i]["faceImg"];
					if(faceImg!=""){
						faceImg = faceImg.replace("/blog/images/",baseUrl); 
						faceImg = "<img src=\""+faceImg+"\">";
					}
					if(xqspan){
						$(xqspan[index]).html(faceImg);
					}
					
				}
				if(isSignInOrSignOut==1){
					var isLate = false;
					var isAbsent = true;
					
					if(i<scheduleReportList.length){
						isLate = scheduleReportList[i]["isLate"];
						isAbsent = scheduleReportList[i]["isAbsent"];
					}
					var scheduleHtml = "";
					if(isLate){
						scheduleHtml = "<img src=\""+signNo+"\">";
					}else if(isAbsent){
						scheduleHtml = "<img src=\""+signAbsent+"\">";
					}else {
						scheduleHtml = "<img src=\""+signOk+"\">";
					}
					if(kqspan){
						$(kqspan[index]).html(scheduleHtml);
					}
					
				}
				index++;
			}
		}
	}else if(ctype=="myAttentionReport"){//关注报表
		var resultList = data["resultList"];
		if(resultList.length==0){
			$("#myAttentionReport_div > .scrollerDiv").hide();
			$("#myAttentionReport_div > .nodata_border").show();
			return;
		}else{
			$("#myAttentionReport_div > .scrollerDiv").show();
			$("#myAttentionReport_div > .nodata_border").hide();
		}
		var totaldateList = data["totaldateList"];
		var reportday = $("#"+ctype+"_div .gtTitle tr:nth-child(1) .reportday");
		var reportvalue = $("#"+ctype+"_div .gtContent tr:nth-child(1) .reportvalue");
		var contenttr = $("#"+ctype+"_div .gtContentWrap tr:not(.complate)");
		var fixtr = $("#"+ctype+"_div .fixedGtContentWrap tr:not(.complate)");
		contenttr.remove();
		fixtr.remove();
		
		var colNum = reportday.length;//当前列数
		var dataNum = totaldateList.length;//工作日天数
		var gtTitleTr = $("#"+ctype+"_div .gtTitle tr.complate");//标题tr
		var content_tr = $("#"+ctype+"_div .gtContentWrap .content_tr");//内容tr
		
		if(colNum<dataNum){//需要加列
			for(var i=0;i<dataNum-colNum;i++){
				gtTitleTr.append("<td class=\"reportday\"></td>");
			}
		
			for(var i=0;i<content_tr.length;i++){
				for(var j=0;j<dataNum-colNum;j++){
					$(content_tr[i]).append("<td class=\"reportvalue\"><span class=\"field_viewText\"></span></td>");
				}
			}
		}else if(colNum>dataNum){//需要删除列
			for(var i=0;i<colNum-dataNum;i++){
				$(reportday[colNum-i-1]).remove();
			}
			
			for(var i=0;i<colNum-dataNum;i++){
				$(reportvalue[colNum-i-1]).remove();
			}
		}
		
		
		$("#"+ctype+"_div .reportday").html("");
		$("#"+ctype+"_div .reportvalue .field_viewText").html("");
		reportday = $("#"+ctype+"_div .reportday");
		var count = resultList.length;
		var leftTabTr = $("#"+ctype+"_div .fixedGtContentWrap tr.complate");//左侧区域
		var rightTabTr = $("#"+ctype+"_div .gtContentWrap tr.complate");//右侧区域
		for(var i=0;i<count-1;i++){
			var tr = leftTabTr.clone();
			$("#"+ctype+"_div .fixedGtContentWrap .gtContent").append(tr);
			tr.removeClass("complate");
			
			var tr1 = rightTabTr.clone();
			$("#"+ctype+"_div .gtContentWrap .gtContent").append(tr1);
			tr1.removeClass("complate");
		}
		for(var i=0;i<totaldateList.length;i++){
			$(reportday[i]).html(totaldateList[i]);
		}
		//填充内容
		var namefield = $("#"+ctype+"_div .fixedGtWrap .reportvalue .field_viewText");
		var field_viewTitle = $("#"+ctype+"_div .gtContentWrap .field_viewTitle");
		for(var i=0;i<count;i++){
			var submitList = resultList[i]["submitList"];
			var name = resultList[i]["name"];
			var userimgUrl = resultList[i]["userimg"];
			$(namefield[i]).html("<img src='"+userimgUrl+"'/>"+name);
			$(field_viewTitle[i]).html("<img src='"+userimgUrl+"'/>"+name);
			var tr = $($("#"+ctype+"_div .gtContentWrap .content_tr")[i]);
			for(var j=0;j<submitList.length;j++){
				var b = submitList[j];
				var submitHtml = "";
				if(b){
					submitHtml = "<div class='submitOk'></div>";
				}else{
					submitHtml = "<div class='submitNo'></div>";
				}
				var valuefield = $($(".field_viewText",tr)[j]);
				valuefield.html(submitHtml);
			}
		}
	}
	$("#more" + theid).hide();
	$("#nodata" + theid).hide();
}

function initScrollH(ctype){
	if(ctype=="myAttentionReport"){
		if(!hScroll1){
			hScroll1 = new IScroll("#"+ctype+"_div .gtWrap", {
				 scrollX: true, scrollY: false, mouseWheel: true
			});
		}else{
			hScroll1.refresh();
			hScroll1.scrollTo(0,0 );
		}
	}else{
		if(!hScroll2){
			hScroll2 = new IScroll("#"+ctype+"_div .gtWrap", {
				 scrollX: true, scrollY: false, mouseWheel: true
			});
		}else{
			hScroll2.refresh();
			hScroll2.scrollTo(0, 0);
		}
	}
}

/**
 * 
 * @param {Object} type
 * @param {Object} liid
 * @param {Object} groupid
 */
function createBlog(type,liid,groupid,dateStr,contents){
	$(".useLocationDiv").removeClass("active");
	$(".locationDesc").html("所在位置");
	if(type==1){
		$(".useLocationDiv").removeClass("hide");
	}else{
		$(".useLocationDiv").addClass("hide");
	}
	setBtnDisable(".btn",false);
	var title = "";
	var placeholder = ""; 
	var $li;
	var panelContent = $("#replayPanel");
	if(type==1){
		placeholder = "请填写工作微博...";
		panelContent.attr("tid","");
		panelContent.attr("type",type);
		panelContent.attr("groupid",1);
	}else if(type==2){
		$li = $("#"+liid);
		var username = $li.attr("username");
		placeholder = "评论@"+username;
		panelContent.attr("tid",liid);
		panelContent.attr("type",type);
		panelContent.attr("groupid",groupid);
	}else if(type==3){
		$li = $("#"+liid);
		var username = $li.attr("username");
		placeholder = "私评@"+username;
		panelContent.attr("tid",liid);
		panelContent.attr("type",type);
		panelContent.attr("groupid",groupid);
	}else if(type==4){
		$li = $("#"+liid);
		var workdate = $li.attr("workdate");
		placeholder = "补交"+workdate+"微博";
		if(dateStr){
			placeholder = "补交"+dateStr+"微博";
		}
		panelContent.attr("tid",liid);
		panelContent.attr("type",type);
		panelContent.attr("groupid",groupid);
	}else if(type==5){
		$li = $("#"+liid);
		var workdate = $li.attr("workdate");
		placeholder = "编辑"+workdate+"微博";
		if(dateStr){
			placeholder = "编辑"+dateStr+"微博";
		}
		panelContent.attr("tid",liid);
		panelContent.attr("type",type);
		panelContent.attr("groupid",groupid);
	}
	toShowReplayPanel(groupid);
	if(contents){
		contents = decodeURIComponent(contents);
		$("#replayContent").val(contents).attr("placeholder",placeholder);
	}else{
		$("#replayContent").val("").attr("placeholder",placeholder);
	}
	
	if(type==5){
		highEditor("replayContent", 200);
		KE.html("replayContent", contents);
	}
}

function getLocation(obj,f){
	Mobile_NS.getCurrentPosition(function(result){
	    var status = result["status"];
	    $("#replayPanel").attr("status",status);
	    if(status == "1"){
	        var lng = result["lng"];      
	        var lat = result["lat"];        
	        var addr = result["addr"]; 
	        var time = new Date().getTime();
	        $("#replayPanel").attr("lng",lng);
	        $("#replayPanel").attr("lat",lat);
	        $("#replayPanel").attr("addr",addr);
	        $("#replayPanel").attr("time",time);
	        if(f){
	        	$(".locationDesc").html(addr);
	        	$(".useLocationDiv").addClass("active");
	        }
	    }else{
	    	if(f){
	    	 	var errMsg = result["errMsg"];
	    		$(".locationDesc").html(errMsg);
	    		$(".useLocationDiv").removeClass("active");
	    	}
	    }
	    if(obj){
	    	doSave(obj);
	    }
	});
}

function useLocation(obj){
	if(!$(obj).hasClass("active")){
		$(".locationDesc").html("定位中...");
		getLoc(true);
	}else{
		$(obj).removeClass("active");
		$(".locationDesc").html("所在位置");
	}
}

function getLoc(f){
	var t = $("#replayPanel").attr("time");
	var status = $("#replayPanel").attr("status");
	t = parseInt(t);
	var now  = new Date().getTime();
	var outtime = 1000*60*3;//3分钟地理位置失效
	if(status==1){
		if((now-t)>outtime){
			getLocation(false,f);
		}else{
			if(f){
				var addr = $("#replayPanel").attr("addr");
				$(".locationDesc").html(addr);
				$(".useLocationDiv").addClass("active");
			}
		}
	}else{
		getLocation(false,f);
	}
}


function createBlog1(obj){
	var li = $(obj).closest("li");
	var id = li.attr("id");
	var groupid = li.attr("groupid");
	createBlog(4,id,groupid);
}

function setBtnDisable(obj,f){
	if(f){
		$(obj).addClass("disable")
	}else{
		$(obj).removeClass("disable")
	}
}

function doCancel(obj){
	doHistoryBack();
}

function doSubmit(obj){
	if($(obj).hasClass("disable")){
		return;
	}
	setBtnDisable(obj,true);
	var type = $("#replayPanel").attr("type");
	if(type==1){//新建微博和补交微博
		if($(".useLocationDiv").hasClass("active")){
			var status = $("#replayPanel").attr("status");
			if(status==null||status!=1){
				getLocation(obj);
			}else{
				var t = $("#replayPanel").attr("time");
				t = parseInt(t);
				var now  = new Date().getTime();
				var outtime = 1000*60*3;//3分钟地理位置失效
				if(status==1){
					if((now-t)>outtime){
						getLocation(obj);
					}else{
						doSave(obj);
					}
				}else{
					getLocation(obj);
				}
			}
		}else{
			doSave(obj);
		}
	}else{
		doSave(obj);
	}
}

function doSave(obj){
	var panelContent = $("#replayPanel");
	var type = panelContent.attr("type");
	var tid = panelContent.attr("tid");
	var groupid = panelContent.attr("groupid");
	var discussid = 0;
	if(type==5){
		$("#replayContent").val(K.g["replayContent"].html());
		K.sync("#replayContent"); //同步内容
	}
	var content = $("#replayContent").val();
	var forDate = "";
	if(content==""){
		alert("请输入内容");
		setBtnDisable(obj,false);
		return;
	}
	
	if(type != 5){
		content = content.replace(new RegExp(/(\n)/g),'<br>');
	}
	var operation = "saveBlog";
	var param = "";
	var li = $("#"+tid);
	var isneedRefresh = false;
	if(type==1||type==4||type==5){
		isneedRefresh = true;
		operation = "saveBlog";
		if(type==4||type==5){
			forDate = li.attr("workdate");
		}
		if(type==5 && li.length>0){
			discussid = li.attr("disid");
		}
		var status = $("#replayPanel").attr("status");
		param = "&discussid="+discussid+"&forDate="+forDate+"&type="+type;
		if(status==1){
			if($(".useLocationDiv").hasClass("active")&&!$(".useLocationDiv").hasClass("hide")){
				var lng = $("#replayPanel").attr("lng");
				var lat = $("#replayPanel").attr("lat");
				var addr = $("#replayPanel").attr("addr");
				param += "&lng="+lng+"&lat="+lat+"&addr="+addr;
			}
		}
		
	}else if(type==2||type==3){
		operation = "pl";
		var uid = "";
		if(li.length>0){
			discussid = li.attr("disid");
			forDate = li.attr("workdate");
			uid = li.attr("userid");
		}
		var commentType = 0;
		if(type==3){
			commentType = 1;
		}
		param+= "&replyid=0&relatedid=0&commentType="+commentType+"&workdate="+forDate+"&bediscussantid="+uid;
	}
	
	content = encodeURIComponent(content);
	//url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation="+operation+"&userid="+userid+"&content="+content+param;
	url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp";
	var urlParams = "operation="+operation+"&userid="+userid+"&content="+content+param;
	var data = new Object();
    var arr1 = urlParams.split("&");
    for(var i = 0; i < arr1.length; i++) {
        var arr2 = arr1[i].split("=");
        data[arr2[0]] = arr2[1];
    }
    $.post(url, data, function(responseText){
		if(isneedRefresh){
			if(groupid==0){
				searchList();
			}else if(groupid==1){
				pageindex1 = 1;
				$("#main-panel-1 .tab .selected").attr("enddate","").attr("isload","0");
				$("#listpanel1 li").remove();
				searchList1("main-panel-"+groupid,"",1);
				setTimeout(function (){
					searchList1("main-panel-"+groupid);
				},10);
			}else if(groupid==2){
				$("#main-panel-2 .tab .selected").attr("enddate","").attr("isload","0");
				$("#listpanel2 li").remove();
				pageindex2 = 1;
				searchList1("main-panel-"+groupid);
			}else if(groupid==4){
				$("#main-panel-4 .tab .selected").attr("enddate","").attr("isload","0");
				$("#listpanel4 li").remove();
				pageindex2 = 1;
				searchList1("main-panel-"+groupid);
			}
		}else{
			var commentReply = $(".commentReply",li);
			if(commentReply.length==0){
				li.append("<div class=\"commentReply\"><ul class=\"reply\"></ul></div>");
			}
			commentReply = $(".commentReply",li);
			var currentuserinfo = $("#currentuserinfo");
			var currentusername = currentuserinfo.attr("currentusername");
			var reply = $("ul.reply",commentReply);
			var htmlStr = "";
			if(type==3){
				htmlStr = "(私评)";
			}
			htmlStr = "<li>"+currentusername+" 刚刚"+htmlStr+"<br><span class='replaycontent'>"+decodeURIComponent(content)+"</span></li>";
			reply.append(htmlStr);
			refreshMainListScroll(groupid);
			//如果评论了第一页的前10条微博，需要后台刷新缓存
			if(groupid==0&&li.index()<(pagesize+1)){
				searchList(true);
			}else if(groupid==1&&li.index()<(pagesize1+1)){
				searchList1("main-panel-1",true);
			}
		}
		setTimeout(function (){
			if(groupid==4){
				doHistoryBack();
			}else{
				toShowListPanel();
				doHistoryBack();
			}
			if(type==5){
				K.g["replayContent"].remove();
				$("#replayContent").text("").show();
			}
		},200);
	});
}



function openBlog(id){
	var selectli = $("#main-panel-4 ul.tab li.selected");
	var blogid = selectli.attr("blogid");
	var openli = $("#li_2_"+id);
	var username = openli.attr("username");
	var userimg = openli.attr("userimg");
	var jbotitle = openli.attr("jbotitle");
	$("#panel4_userimg").attr("src",userimg);
	$("#panel4_userinfo").html(username+"<br /><span>"+jbotitle+"</span>");
	getAttnStatus(id);
	if(blogid==null||blogid!=id){
		$("#main-panel-4 .tab .selected").attr("enddate","").attr("isload","0");
		$("#listpanel4 li").remove();
		pageindex4 = 1;
		selectli.attr("blogid",id);
		$("#main-panel-4 .tbar li.selected").removeClass("selected");
		$("#main-panel-4 .tbar li:nth-child(1)").addClass("selected");
		$("#listpanel4").addClass("listBlog").removeClass("listContainer");
		searchList1("main-panel-4");
	}
	toShowOtherBlog();
	var h = $("#main-panel-4 div.header")[0].clientHeight;
	var listSearch = $("#listSearch4");
	if(!listSearch.hasClass("hide")){
		 h += listSearch[0].clientHeight;
	}
	$("#NMEC_panel4.listContainerWrap").css("top", h);
	setTimeout(function(){
		$("#main-panel-2 li[is_swiped='true']").trigger("swipeRight");
	},100);
	consoleGoTop(4);
}

function toShowOtherBlog(){
	$("#main-panel-4").removeClass("hide");
	pushHistoryState({url:"b"});//切换页面，存入一个history
}

function toShowReplayPanel(groupid){
	if(groupid==4){
		$("#main-panel-4").addClass("hideCurrent");
	}
	$("#replayPanel").removeClass("hide");
	pushHistoryState({url:"a"});//切换页面，存入一个history
}

function toShowListPanel(){
	if(!$("#replayPanel").hasClass("hide")){
		$("#replayPanel").addClass("hide");
	}
	if(!$("#main-panel-4").hasClass("hide")||$("#main-panel-4").hasClass("hideCurrent")){
		$("#main-panel-4").addClass("hide").removeClass("hideCurrent");
	}
	$(".currentPanel").removeClass("hide");
	changeListContainerPosition();
}

function toShowListPanel1(id){
	$("#"+id).addClass("hide");
	if(id=="replayPanel"){
		if($("#main-panel-4").hasClass("hideCurrent")){
			$("#main-panel-4").removeClass("hideCurrent")
		}else{
			$(".currentPanel").removeClass("hide");
		}
	}else{
		$(".currentPanel").removeClass("hide");
	}
}

function doLeftButton(){
	var viewBlogId = parseInt($('#viewBlogId').val());
	if(viewBlogId > 0) {
		return "CLOSE";
	} else {
		var type = $("#replayPanel").attr("type");
		if(type==5){
			K.g["replayContent"].remove();
			$("#replayContent").text("").show();
		}
		return "BACK";
	}
}

function doHistoryBack(){
	var type = $("#replayPanel").attr("type");
	if(type==5){
		K.g["replayContent"].remove();
		$("#replayContent").text("").show();
	}
	history.go(-1);
}

function doBackPage(){
	if(!$("#mapPanel").hasClass("hide")){
		$("#mapPanel").addClass("hide");
		return "1";
	}else if(!$("#replayPanel").hasClass("hide")){
		toShowListPanel1('replayPanel');
		if($("#main-panel-4").hasClass("hideCurrent")){
			$("#main-panel-4").removeClass("hideCurrent");
		}
		return "1";
	}else if(!$("#main-panel-4").hasClass("hide")){
		toShowListPanel1('main-panel-4');
		return "1";
	}else if($("#main-panel-2").hasClass("hide")){
		$("#remindPanel").addClass("hide");
		toShowListPanel1('main-panel-2');
		return "1";
	}
}

 function changeAttention(obj,attentionid,islower,eve){
	 	$("#li_2_"+attentionid,$("#main-panel-2")).trigger("swipeRight");
        var status=obj.getAttribute("status");
		var url = "/mobilemode/apps/e-cology/blog/BlogOperation.jsp?operation=changeAttention&status="+status;
        url = url+"&userid="+userid+"&islower="+islower+"&attentionid="+attentionid;
        if(status=="cancel"||status=="add"){
           var btnText = "添加关注";
           var changeStatus = "add";
           if(status=="add"){
        	   btnText = "取消关注";
        	   changeStatus = "cancel";
           }
			$.get(url, function(){
	            obj.setAttribute("status",changeStatus);
				obj.innerHTML = btnText;
			});
        }
        eve.cancelBubble=true;
}
 


function changeListContainerPosition(){
    var wPositionTop = "0";
    if(indexTab==0){
    	wPositionTop = "0";
    }else if(indexTab==2){
		wPositionTop = "81px";
    }else{
    	wPositionTop = "41px";
    }
    $(".listContainerWrap").css("top", wPositionTop);
}

$(document).ready(function(){
	setTimeout(function(){
		if (history.pushState) {
			history.replaceState({}, "", location.href);
			window.addEventListener("popstate", function(event) {
				if(event && event.state){
		    		doBackPage();
		    	}else{
		    		doHistoryBack();
		    	}
		    });
		}
	}, 100);
});

function pushHistoryState(state, title, url){
	if(!url){
		url = location.href;
		var timestampReg = /(\?|&)timestamp=\d{13}/;
		var timestampMatches = timestampReg.exec(url);
		if(timestampMatches){
			url = url.replace(timestampMatches[0], "");
		}
		if(url.indexOf("?") != -1){
			url += "&timestamp=" + new Date().getTime();
		}else{
			url += "?timestamp=" + new Date().getTime();
		}
	}
	if(!title){
		title = document.title;
	}
	if(!state || typeof(state) != "object"){
		state = {title:title,url:url};
	}
	
	if(history.pushState){
		history.pushState(state, title, url);
		isNeedBackPage = true;
    }
}


function showGotop(groupid){
	var $panel;
	if(groupid==0){
		$panel = $("#main-panel");
	}else{
		$panel = $("#main-panel-"+groupid);
	}
	var $goTop = $(".gotop",$panel);
	if(!$goTop.hasClass("show") && !$goTop.hasClass("show2")){
		$goTop.addClass("show2").addClass("show");
	}
}

function hideGotop(groupid){
	var $panel;
	if(groupid==0){
		$panel = $("#main-panel");
	}else{
		$panel = $("#main-panel-"+groupid);
	}
	var $goTop = $(".gotop",$panel);
	if($goTop.hasClass("show")){
		$goTop.removeClass("show");
		setTimeout(function(){
			$goTop.removeClass("show2");
		}, 282);
	}
}

function moveToTop(groupid){
	var scrollObj;
	if(groupid==0){
		scrollObj = mainListScroll;
	}else if(groupid==1){
		scrollObj = mainListScroll1;
	}else if(groupid==4){
		scrollObj = mainListScroll4;
	}
	scrollObj.refresh();
	scrollObj.scrollTo(0, 0, 500, IScroll.utils.ease.quadratic);
}

function openMap(index){
	var data = locationArr[index-1];
	function innerFn(){
		var h = $(window).height()-$("#scroll_footer")[0].clientHeight;
		$("#mapDiv").css("height",h+"px");
		var b_map = new BMap.Map($("#mapDiv")[0]);
		
		//地图初始化
		b_map.clearOverlays();    //清除地图上所有覆盖物
		b_map.addControl(new BMap.NavigationControl());
		b_map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
		b_map.enableContinuousZoom();     //启用地图惯性拖拽，默认禁用
		
		var pointArr = new Array();
		for(var i=0;i<data.length;i++){
			var location = data[i]["location"];
			var createtime = data[i]["createtime"];
			var locationName = data[i]["locationName"];
			locationName += " "+createtime;
			var lng = location.split(",")[1];
			var lat = location.split(",")[0];
			var point = new BMap.Point(lng, lat);
			var marker = new BMap.Marker(point);
			if(data.length>1){
				pointArr.push(point);
			}
			
			b_map.addOverlay(marker);
			b_map.centerAndZoom(point, 15);
			b_map.setCenter(point);
			showAddress(marker,point,locationName);
			if(data.length>1){
				if(i==data.length-1){
					setTimeout(function(){  
		                b_map.setViewport(pointArr); 
		            },300); 
				}
			}
		}
	}
	
	function showAddress(marker,point,locationName){
		var gc = new BMap.Geocoder();
		gc.getLocation(point, function(rs){
		    var locationLabel=locationName;
		    var label = new BMap.Label(locationLabel,{offset:new BMap.Size(20,-10)});
		    marker.setLabel(label); 
		});
	}
				
	if(typeof(BMap) == "undefined"){
		Mobile_NS.addJs("/mobilemode/apps/e-cology/crm/js/baidu/api_wev8.js", function(){
			Mobile_NS.addJs("/mobilemode/apps/e-cology/crm/js/baidu/convertor_wev8.js", function(){
				innerFn();
			});
		});
	}else{
		innerFn();
	}
	pushHistoryState({url:"b"});//切换页面，存入一个history
	$("#mapPanel").removeClass("hide");
}

//ios键盘右上角两个按钮点击切换输入框的问题
function displayPL(){
	$("#replayPanel").hide();
	$("#remindPanel").hide();
	$("#mapPanel").hide();
}

function showPL(){
	$("#replayPanel").show();
	$("#remindPanel").show();
	$("#mapPanel").show();
}